<template>
	<view class="content">
		当前环境:{{brower}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				brower: '原生'
			}
		},
		onLoad(data) {
			//判断当前浏览器环境
			this.brower = this.getBrower();
			//修改扫码状态
			uni.request({
				url: 'http://49.234.85.206:8000/scan/scan',
				data: {
					token: data.token,
					channel: this.brower
				}
			}).then(res=>{
			})
		},
		methods: {
			getBrower() {
				//window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息，这个属性可以用来判断浏览器类型
				var ua = window.navigator.userAgent.toLowerCase();
				//通过正则表达式匹配ua中是否含有MicroMessenger字符串
				if (ua.match(/MicroMessenger/i) == 'micromessenger') {
					return "weixin";
				} else if (ua.match(/QQ/i) == 'qq') {
					return "qq";
				} else {
					return "unknown";
				}
			}
		}
	}
</script>

<style>
</style>
